﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Telerik.Windows.Data;
using XBMCRemote.DataModel;
using XBMCRemote.DataModel.Entities;

namespace XBMCRemote
{
    public partial class MoviePage : PhoneApplicationPage
    {
        private XbmcHelper _xbmcHelper;
        public MoviePage()
        {
            InitializeComponent();
            
            _xbmcHelper = (App.Current as App).XbmcHelper;
            _xbmcHelper.VideoLibrary.GetMovies();

            _xbmcHelper.SetMovies += XbmcHelperSetMovies;
        }

        private void XbmcHelperSetMovies(object sender, EventArgs e)
        {
            Dispatcher.BeginInvoke(() =>
                                       {
                                           rjlTitles.ItemsSource = _xbmcHelper.Movies;
                                           rjlYears.ItemsSource = _xbmcHelper.Movies;
                                       });
        }
    }
}
